import java.util.Deque;
import java.util.LinkedList;

class MyQueue {
    Deque<Integer> stack1;
    Deque<Integer> stack2;
    public MyQueue() {
    stack1 = new LinkedList<>();
    stack2 = new LinkedList<>();
    }
    
    public void push(int x) {
    stack1.push(x);
    }
    
    public int pop() {
    if(!stack2.isEmpty()){
        return stack2.pop();
    }
    while(!stack1.isEmpty()) {
        stack2.push(stack1.pop());
    }
    return stack2.pop();
    }
    
    public int peek() {
        if(!stack2.isEmpty()){
            return stack2.peek();
        }
        while(!stack1.isEmpty()) {
            stack2.push(stack1.pop());
        }
        return stack2.peek();
    }

    
    public boolean empty() {
    if(stack2.isEmpty()&&stack1.isEmpty()){
        return true;
    }
    return false;
    }
}